////////////////////////////////////////////////////////////////////////
// Projekt  : Wirtschaftssimulation                Datum: 16.04.2012  //
// Autor    : Lukas Sauer                                             //
//                                                                    //
////////////////////////////////////////////////////////////////////////




//#include "stdafx.h"
#include "cstdlib"
#include "time.h"
#include "stdio.h"

#define ARRAYSIZE 80
#define LOOPS 100


void printSauerLukasSimulation()
{

	int zeile[ARRAYSIZE];
	int temp[ARRAYSIZE];

	int count = 0;

	int i = 0;

	time_t t;
	time(&t);
	srand((unsigned int)t);

	for (int y = 0; y < LOOPS; y++)
	{
		for(int x = 0; x < ARRAYSIZE; x++)
		{
			if(y == 0)
			{
				zeile[x] = rand () %2;
				printf("%i ", zeile[x]);
				if(x == ARRAYSIZE-1)
				{
					printf("\n");
				}
			}
			else if (y >0)
			{
				if(zeile[x] == 1)
				{
					count++;
				}
				if(zeile[x-1] == 1)
				{
					count++;
				}
				if(zeile[x-2] == 1)
				{
					count++;
				}
				if(zeile[x+1] == 1)
				{
					count++;
				}
				if(zeile[x+2] == 1)
				{
					count++;
				}
				if(count == 2 || count ==4)
				{
				temp[x] = 1;
				}
				else
				{
					temp[x] = 0;
				}
				printf("%i ", temp[x]);
				if(x == ARRAYSIZE-1)
				{
					for (int i = 0; i < ARRAYSIZE; i++)
					{
						zeile[i] = temp[i];
					}
					printf("\n");
				}
				count = 0;
			}
		}
	}
	getchar();

}

